version: '3'

volumes:
  pg_data:
  static:
  media:

services:
  db:
    image: postgres:13
    env_file: .env
    volumes:
      - pg_data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: your_password


  backend:
    build: ./backend/
    env_file: .env
    depends_on:
      - db
    volumes:
      - static:/backend_static
      - media:/app/media/

  frontend:
    build: ./frontend/
    env_file: .env
    command: cp -r /app/build/. /frontend_static/ 
    volumes:
      - static:/frontend_static

  nginx:
    build: ./infra/
    env_file: .env
    depends_on:
      - backend
      - frontend
    volumes:
      - static:/staticfiles/
      - media:/media
    ports:
      - 8000:80
